home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------*/
- /* */
- /* SCRLWIN.CPP */
- /* */
- /* Implements non-inline functions from SCRLWIN.H */
- /* */
- /*------------------------------------------------------------------------*/
-
- #include "scrlwin.h"
-
- /*------------------------------------------------------------------------*/
- /* */
- /* Member functions of Scroller. */
- /* */
- /*------------------------------------------------------------------------*/
-
- void Scroller::SetTextSize( int sz )
- {
- TextSize = sz;
- if( Pos > sz )
- Pos = sz;
- SetScrollRange( GetHandle(), Which, 0, TextSize, FALSE );
- SetScrollPos( GetHandle(), Which, Pos, TRUE );
- }
-
- void Scroller::SetWinSize( int sz )
- {
- if( Pos > sz )
- Pos = sz;
- SetScrollPos( GetHandle(), Which, Pos, TRUE );
- }
-
- long Scroller::OnScroll( unsigned where )
- {
- int delta;
- switch( where )
- {
- case SB_LINEUP:
- delta = -1;
- break;
- case SB_LINEDOWN:
- delta = 1;
- break;
- case SB_PAGEUP:
- delta = min( -1, -GetPageSize() );
- break;
- case SB_PAGEDOWN:
- delta = max( 1, GetPageSize() );
- break;
- default:
- delta = 0;
- break;
- }
- delta = max( -Pos, min( delta, int(TextSize-Pos-GetPageSize()) ) );
- if( delta != 0 )
- {
- Pos += delta;
- if( Which == Vert )
- ScrollWindow( GetHandle(), 0, -GetCharHeight()*delta, 0, 0 );
- else
- ScrollWindow( GetHandle(), -GetCharWidth()*delta, 0, 0, 0 );
- SetScrollPos( GetHandle(), Which, Pos, TRUE );
- UpdateWindow( GetHandle() );
- }
- return 0;
- }
-
- /*------------------------------------------------------------------------*/
- /* */
- /* Member functions and static member data of VScroller */
- /* */
- /*------------------------------------------------------------------------*/
-
- BI_SVectorImp<DispatchRecord<VScroller> > VScroller::Map( 10, 5 );
-
- int VScroller::Dispatch( UINT msg, UINT w, LONG l, LONG& res )
- {
- unsigned loc = Map.find( DispatchRecord<VScroller>( msg, VoidType, 0 ) );
- if( loc == UINT_MAX )
- return 0;
- else
- {
- DispatchRecord<VScroller> entry = Map[loc];
- DispatchRecord<VScroller>::VoidFunc proc = entry.Proc;
- switch( entry.Type )
- {
- case VoidType:
- res = (this->*(DispatchRecord<VScroller>::VoidFunc)proc)();
- break;
- case UUType:
- res = (this->*(DispatchRecord<VScroller>::UUFunc)proc)( LOWORD(l),
- HIWORD(l) );
- break;
- case UType:
- res = (this->*(DispatchRecord<VScroller>::UFunc)proc)( w );
- break;
- }
- return 1;
- }
- }
-
- /*------------------------------------------------------------------------*/
- /* */
- /* Member functions and static member data of HScroller */
- /* */
- /*------------------------------------------------------------------------*/
-
- BI_SVectorImp<DispatchRecord<HScroller> > HScroller::Map( 10, 5 );
-
- int HScroller::Dispatch( UINT msg, UINT w, LONG l, LONG& res )
- {
- unsigned loc = Map.find( DispatchRecord<HScroller>( msg, VoidType, 0 ) );
- if( loc == UINT_MAX )
- return 0;
- else
- {
- DispatchRecord<HScroller> entry = Map[loc];
- DispatchRecord<HScroller>::VoidFunc proc = entry.Proc;
- switch( entry.Type )
- {
- case VoidType:
- res = (this->*(DispatchRecord<HScroller>::VoidFunc)proc)();
- break;
- case UUType:
- res = (this->*(DispatchRecord<HScroller>::UUFunc)proc)( LOWORD(l),
- HIWORD(l) );
- break;
- case UType:
- res = (this->*(DispatchRecord<HScroller>::UFunc)proc)( w );
- break;
- }
- return 1;
- }
- }
-
- /*------------------------------------------------------------------------*/
- /* */
- /* Member functions of ScrollableText */
- /* */
- /*------------------------------------------------------------------------*/
-
- int ScrollableText::Dispatch( UINT msg, UINT w, LONG l, LONG& res )
- {
- if( TextWindow::Dispatch( msg, w, l, res ) ||
- VScroller::Dispatch( msg, w, l, res ) ||
- HScroller::Dispatch( msg, w, l, res )
- )
- return 1;
- else
- return 0;
- }
-
-